home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d953.lha / LHA_DOpus / LHA.dopus next >
Text File  |  1993-11-12  |  4KB  |  194 lines

  1. /* DOPUS-LHA AREXX SCRIPT by Michiel Pelt
  2.  *
  3.  * Lists selected archive in current window and installs handler to deal
  4.  * with it.
  5.  * Double-click on 'Quit' to quit
  6.  * Double-click on 'AddFiles' to add all selected files to the archive
  7.  * Double-click on 'ExtractSelected' to extract all selected files from the archive
  8.  * Double-click on 'RemoveSelected' to remove all selected files from the archive
  9.  * Click-m-click or double-click on files to extract single files
  10. */
  11.  
  12. address 'DOPUS.1'
  13. options results
  14.  
  15. 'busy on'
  16. 'toptext' 'lha interface'
  17.  
  18. /* add rexxsupport.library */
  19. IF ~SHOW('L', "rexxsupport.library") THEN DO
  20.     IF ADDLIB("rexxsupport.library",0,-30,0) THEN
  21.         'TopText' "Opened rexxsupport.library."
  22.     ELSE DO
  23.         'TopText' "Rexxsupport.library not found"
  24.         EXIT 10
  25.     END
  26. END
  27.  
  28. /* get archive */
  29. 'getnextselected'
  30. archiefname = result
  31. 'status 13 -1'    /* current directory */
  32. path = result
  33. archief = '"'path || archiefname'"'
  34.  
  35. OPENPORT('LHAPort')
  36. CALL ShowArchive
  37.  
  38. 'busy off'
  39.  
  40. DO FOREVER
  41.     IF WAITPKT('LHAPort') THEN 
  42.     DO
  43.         pakket = GETPKT('LHAPort')
  44.         actie  = GETARG(pakket, 0)
  45.         i      = GETARG(pakket, 1)
  46.         text   = GETARG(pakket, 2)
  47.         user   = GETARG(pakket, 3)
  48.  
  49.         REPLY(pakket, 0)
  50.  
  51.         'busy on'
  52.  
  53.         IF actie=1 THEN    'OtherWindow'    /* destwindow active */
  54.  
  55.         IF user=1 THEN                /* 'quit' */
  56.         DO
  57.             'OtherWindow'
  58.             'busy off'
  59.             'ClearWin'
  60.             EXIT
  61.         END
  62.  
  63.         ELSE IF user = 2 THEN        /* addfiles */
  64.         IF actie = 1 THEN            /* double-click */
  65.         DO
  66.             'status 13 -1'            /* destination path */
  67.             destpath = '"'result'"'
  68.             'GetNextSelected'
  69.             filename = result
  70.             DO WHILE ~(filename = 0)
  71.                 ADDRESS COMMAND 'c:lha -axr a' archief destpath filename
  72.                 'SelectFile' filename 0 1
  73.                 'GetNextSelected'
  74.                 filename = result
  75.             END
  76.             'OtherWindow'
  77.             CALL ShowArchive
  78.         END 
  79.         ELSE NOP
  80.  
  81.         ELSE IF user = 3 THEN        /* extract files */
  82.         DO
  83.             'status 13 -1'            /* destination path */
  84.             destpath = '"'result'"'
  85.             'OtherWindow'
  86.  
  87.             'GetSelectedAll'
  88.             nums = result
  89.             DO WHILE (nums~='')
  90.                 PARSE VAR nums num nums
  91.                 IF ~(num=='') THEN
  92.                 DO
  93.                     'GetEntry' num+1
  94.                     text = result
  95.                     PARSE VAR text filename .
  96.                     ADDRESS COMMAND 'c:lha x' archief destpath filename
  97.                 END
  98.             END
  99.     
  100.             'OtherWindow'                
  101.             'Rescan'
  102.             'OtherWindow'
  103.         END
  104.  
  105.         ELSE IF user = 4 THEN        /* remove files */
  106.         DO
  107.             'OtherWindow'
  108.  
  109.             'GetSelectedAll'
  110.             nums = result
  111.             DO WHILE (nums~='') 
  112.                 PARSE VAR nums num nums
  113.                 IF ~(num=='') THEN
  114.                 DO
  115.                     'GetEntry' num+1
  116.                     text = result
  117.                     PARSE VAR text filename .
  118.                     ADDRESS COMMAND 'c:lha d' archief filename
  119.                 END
  120.             END
  121.  
  122.             CALL ShowArchive
  123.         END
  124.  
  125.  
  126.         ELSE 
  127.         DO                /* extract doubleclicked or clickmclicked files */
  128.             'status 13 -1'
  129.             destpath = '"'result'"'
  130.  
  131.             PARSE VAR text filename osize date time .
  132.             ADDRESS COMMAND 'c:lha x' archief destpath filename
  133.             'Rescan'
  134.  
  135.             'OtherWindow'
  136.         END
  137.         
  138.         'busy off'
  139.     END
  140. END
  141.  
  142. /* open lha archive and list in window */
  143. /* archivename should be in 'archief' */
  144. ShowArchive:
  145.  
  146.     ADDRESS COMMAND 'c:lha >t:file v' archief
  147.     IF RC>0 THEN DO
  148.         'TopText' "LHA-error"
  149.         EXIT 10
  150.     END
  151.  
  152.     'ClearWin'
  153.     'SetWinTitle' archiefname
  154.     OPEN('file','t:file','R')
  155.  
  156.     /* control entries in red */
  157.     'AddCustEntry Quit 1 7 -1 1 1'
  158.     'AddCustEntry AddFiles 2 7 -1 1 1'
  159.     'AddCustEntry ExtractSelected 3 7 -1 1 1'
  160.     'AddCustEntry RemoveSelected 4 7 -1 1 1'
  161.  
  162.     /* skip status lines */
  163.     DO i=1 TO 5 WHILE ~EOF('file')
  164.         entry = READLN('file')
  165.     END
  166.  
  167.     stop = 0
  168.     DO WHILE (~EOF('file') & (stop ~= 1))
  169.         entry = READLN('file')
  170.         /* skip comment lines */
  171.         IF ~(LEFT(entry,1) == ':') THEN 
  172.         DO    
  173.             PARSE VAR entry osize psize ratio date time filename .
  174.             entry = filename
  175.             IF LENGTH(entry)>0 THEN
  176.             DO
  177.                 pos = MAX(50,10*((LENGTH(entry)+LENGTH(osize)+2)%10+1))
  178.                 entry = OVERLAY(osize, entry, pos - LENGTH(osize))
  179.                 entry = OVERLAY(date, entry, pos + 1)
  180.                 entry = OVERLAY(time, entry, pos + 11)
  181.                 entry = '"'entry'"'
  182.                 'AddCustEntry' entry '5 -1 -1 1 1'
  183.             END
  184.             ELSE stop = 1
  185.         END
  186.     END
  187.  
  188.     CLOSE('file')
  189.     'delete t:file'
  190.  
  191.     'AddCustHandler LHAPort'
  192.  
  193.     RETURN
  194.